package javabase.schoolwork.day6_07;

/**
 * @author fance
 * @date 2018/6/7 20:18
 */
class ThreadSleepI implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}
class ThreadPriority implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}
public class ThreadSleep {
    public static void main(String[] args) {
//        new Thread(new ThreadSleepI()).start();
       Thread thread1 =  new Thread(new ThreadPriority(),"A");
        Thread thread2 = new Thread(new ThreadPriority(),"B");
        Thread thread3 = new Thread(new ThreadPriority(),"C");
        thread1.setPriority(Thread.MIN_PRIORITY);
        thread2.setPriority(Thread.NORM_PRIORITY);
        thread3.setPriority(Thread.MAX_PRIORITY);
        thread1.start();
        thread2.start();
        thread3.start();
    }
}
